Imports System.Net.Sockets
Imports System.Threading
'imports System.Security
Module modError
    Public Sub DoError(ByRef e As Exception)
        Dim lcMessage As String
        Try
            lcMessage = _
                "An unhandled error has occured!" _
                + vbNewLine + "Error: " + e.Message _
                + vbNewLine + "Source:" + e.Source _
                + vbNewLine + "Method:" + e.TargetSite.Name _
                + vbNewLine + "Stack Trace:" + e.StackTrace _
                + vbNewLine + "Exception:" + e.InnerException.ToString
        Catch ex As Exception
            DoError(ex)
        End Try
        MsgBox(lcMessage)
    End Sub
    Public Sub DoError(ByVal e As System.NullReferenceException)
        Dim lcMessage As String = _
            "An unhandled error has occured!" _
            + vbNewLine + "Error: " + e.Message _
            + vbNewLine + "Source:" + e.Source _
            + vbNewLine + "Method:" + e.TargetSite.Name _
            + vbNewLine + "Stack Trace:" + e.StackTrace _
            + vbNewLine + "Exception:" + e.InnerException.ToString
        MsgBox(lcMessage)
    End Sub
End Module